<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>开始使用layui</title>
  <link rel="stylesheet" href="../layui/css/layui.css">
</head>
<body>
 

<script src="../layui/layui.js"></script>
<script>

、/**
  * 定义模块 方式 1
  */
layui.define(function(exports){
  
  console.log("123456789");
  
  exports('demo', function(){
    alert('Hello World!');
  });
});
    
  layui.demo(); 
  
/**
 * 定义模块 方式 2   
 */

//config的设置是全局的
layui.config({
  base: '/layui/modules/' //假设这是mymod.js所在的目录
});
 
//mymod
layui.use('mymod', function(){
  var mymod = layui.mymod;
  
  mymod.hello('World!'); //弹出Hello World!
});

// 练习 
layui.config({
    base:  '/layui/modules/'   //模块存放的目录  base: '/static/admin/js/module/'
}).use(['jquery','element','form','login'],function () {
    var $ = layui.jquery,
        form = layui.form,
        element = layui.element,
        login = layui.login;
    form.on("submit(subBtn)",function (data) {
        //获取表单的值
        var field = data.field;
        login.login("{:url('Login/doLogin')}",field,$,"{:url('Index/index')}");
        return false;
    });
});



 
</script>

</body>
</html>
